//export const baseURL = "http://192.168.137.1:8080" 
export const baseURL = "http://localhost:8080"
export const PyBaseURL = "http://127.0.0.1:5000"
export const MapBaseURL = "https://apis.map.qq.com"

export function MapRequest(options) {
 
  return new Promise((resolve, reject) => {
    wx.request({
      url: MapBaseURL + options.url,
      data: options.data || {},
      method: options.method || 'get',
      success: res => {
        resolve(res)
      },
      fail: err => {
        reject(err)
      }
    })
  })
}

export function PyRequest(options) {
  return new Promise((resolve, reject) => {
    wx.request({
      url: PyBaseURL + options.url,
      data: options.data || {},
      header: options.header || {
        'Content-Type': 'application/json'
      },
      method: options.method || 'get',
      success: res => {
        resolve(res)
      },
      fail: err => {
        reject(err)
      }
    })
  })
}


export function request(options) {
  return new Promise((resolve, reject) => {
    wx.request({
      url: baseURL + options.url,
      data: options.data || {},
      method: options.method || 'get',
      success: res => {
        resolve(res)
      },
      fail: err => {
        reject(err)
      }
    })
  })
}